<?php
require_once('nrg/dom.class.js');
?>

var Nrg_App = new Class({
	
	Implements: [Options],
	
	reg: {},
	
	themes: {},
	
	options: {},
	
	//--------------------------------------------------------------------------
	//--------------------------------------------------------------------------
	
	/**
	 * Constructor.
	 */
	initialize: function(options)
	{
		this.setOptions(options);
	},
	
	//--------------------------------------------------------------------------
	
	/**
	 * Adds a theme object to the theme registry.
	 * @return Nrg_App
	 */
	addTheme: function(name, Theme)
	{
		if ( ! instanceOf(Theme, Nrg_Uiw_Theme) ) {
			throw new Nrg_Exception(
				'Theme must be an instance of Nrg_Uiw_Theme'
			);
		}
		this.themes[name] = Theme;
		return this;
	},
	
	//--------------------------------------------------------------------------
	
	/**
	 * Sets the themes.
	 * @return Nrg_App
	 */
	setThemes: function(themes_assoc)
	{
		this.clearThemes();
		for ( var i in themes_assoc ) {
			this.addTheme(i, Theme);
		}
		return this;
	},
	
	//--------------------------------------------------------------------------
	
	/**
	 * Removes all theme object from app theme registry.
	 * @return Nrg_App
	 */
	clearThemes: function()
	{
		this.themes = {};
		return this;
	},
	
	//--------------------------------------------------------------------------
	
	/**
	 * Get theme object of given name.
	 * @return Nrg_Uiw_Theme
	 */
	getTheme: function(name)
	{
		for ( i in this.themes ) {
			if ( i == name ) {
				return theme;
			}
		}
		return undefined;
	}
	
	//--------------------------------------------------------------------------
});